using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using MacomberMap.Common.User_Interfaces.Components;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using MacomberMap.Common.User_Interfaces.One_Lines.Elements;
using MacomberMap.Common.Components;
using MacomberMap.Common.Types;
using MacomberMap.Common.Database_Interface;
using System.Drawing.Drawing2D;

namespace MacomberMap.Common.User_Interfaces.One_Lines.Elements
{
    /// <summary>
    /// This class provides a viewable Reactor
    /// </summary>
    public class MM_OneLine_Reactor : MM_OneLine_Element
    {        
        #region Initialization
        /// <summary>
        /// Initialize a new viewable Reactor
        /// </summary>
        /// <param name="ElemConfig">The Xml configuration for the Reactor</param>
        /// <param name="DisplayParameters">The display parameters for the Reactor</param>
        /// <param name="DbConnection">The database connection</param>
        public MM_OneLine_Reactor(XmlElement ElemConfig, MM_OneLine_Display DisplayParameters, MM_Database DbConnection)
            : base(ElemConfig, DisplayParameters, DbConnection)
        {
            //Retrieve our arrow direction from the Reactor
            Orientation = ParseOrientation(ElemConfig.Attributes["Orientation"].Value);

            
        }

         /// <summary>
        /// Initialize a new viewable Reactor
        /// </summary>
        /// <param name="BaseElement">The CIM element upon which the Reactor is based</param>
        /// <param name="DisplayParameters">The display parameters for the Reactor</param>
        /// <param name="Orientation">The orientation of the reactor</param>
        public MM_OneLine_Reactor(MM_Element BaseElement, MM_OneLine_Display DisplayParameters, MM_OneLine_Element.enumOrientations Orientation)
            : base(BaseElement, DisplayParameters, Orientation)
        {                        
        }
        
        #endregion


        #region Rendering
        /// <summary>
        /// Draw the reactor
        /// </summary>
        /// <param name="g"></param>
        public override void DrawImage(Graphics g)
        {
            Point[] OutPoints = OutPoints= IntToPoints(0, 12, 1, 12, 2, 13, 3, 15, 4, 18, 5, 20, 6, 22, 7, 23, 8, 24, 10, 24, 12, 23, 14, 21, 15, 19, 16, 16, 17, 12, 17, 7, 16, 4, 15, 2, 12, 0, 10, 0, 8, 1, 6, 3, 5, 6, 5, 11, 7, 17, 8, 19, 10, 22, 11, 23, 13, 24, 15, 24, 16, 24, 18, 23, 19, 22, 21, 19, 22, 16, 23, 12, 23, 7, 22, 4, 21, 2, 18, 0, 16, 0, 14, 1, 13, 2, 12, 3, 11, 5, 10, 8, 10, 12, 11, 15, 13, 19, 15, 22, 18, 24, 20, 24, 22, 23, 23, 22, 25, 19, 26, 16, 27, 13, 28, 12, 30, 12, 32, 12);
            if (Orientation == enumOrientations.Vertical || Orientation == enumOrientations.Up || Orientation == enumOrientations.Down)
                for (int a = 0; a < OutPoints.Length; a++)                
                    OutPoints[a] = new Point(OutPoints[a].Y, OutPoints[a].X);                                
            using (SolidBrush BackBrush = new SolidBrush(BackColor))
                g.FillRectangle(BackBrush, DisplayRectangle);
            g.DrawLines((KVLevel != null ? KVLevel.Energized.ForePen : Pens.Red), OutPoints);
            
        }



        /// <summary>
        /// Draw the Reactor text
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextLabel_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawString("Text here.", SystemFonts.CaptionFont, Brushes.Aqua, PointF.Empty);
            //throw new Exception("The method or operation is not implemented.");
        }
        #endregion
    }
}


